home *** CD-ROM | disk | FTP | other *** search
- global gStackLevel, gStack, gDebug
-
- on head str, x
- if x > 0 then
- return char 1 to x of str
- else
- if x < 0 then
- return char 1 to length(str) + x of str
- else
- return EMPTY
- end if
- end if
- end
-
- on tail str, x
- if x > 0 then
- return char length(str) - x + 1 to length(str) of str
- else
- if x < 0 then
- return char -x + 1 to length(str) of str
- else
- return EMPTY
- end if
- end if
- end
-
- on pad n
- if n < 10 then
- return "0" & string(n)
- else
- return string(n)
- end if
- end
-
- on waitTicks t
- set endTicks to the ticks + t
- repeat while the ticks < endTicks
- nothing()
- end repeat
- end
-
- on doToolClick which
- set x to the mouseH
- set y to the mouseV
- set numTools to the number of lines in the text of cast which
- repeat with i = 1 to numTools
- set toolLine to line i of the text of cast which
- if withinBox(item 1 of toolLine, item 2 of toolLine, item 3 of toolLine, item 4 of toolLine, x, y) then
- if item 6 of toolLine <> "0" then
- setOverlayPuppet(value(item 1 of toolLine), value(item 2 of toolLine), value(item 6 of toolLine))
- updateStage()
- if value(item 7 of toolLine) <> 0 then
- clickRoutine(item 5 of toolLine)
- if value(item 7 of toolLine) = 1 then
- repeat while the mouseDown
- end repeat
- end if
- hideOverlay()
- else
- hideOverlay()
- clickRoutine(item 5 of toolLine)
- end if
- else
- clickRoutine(item 5 of toolLine)
- end if
- exit repeat
- end if
- end repeat
- end
-
- on clickRoutine pr
- global gHasPressed
- set command to word 1 of pr
- set param to word 2 of pr
- if command = "adjTime" then
- adjTime(param)
- else
- if command = "go" then
- do("go " && param)
- else
- if command = "giveResponse" then
- set gHasPressed to 0
- giveResponse(value(param))
- else
- if command = "goMenu" then
- repeat while the mouseDown
- end repeat
- goMenu()
- else
- if command = "doRecord" then
- doRecord()
- else
- if command = "doPlayRecord" then
- doPlayRecord()
- else
- if command = "changeScreen" then
- changeScreen(value(param))
- else
- if command = "goControls" then
- goControls()
- else
- if command = "toggleBrowse" then
- toggleBrowse()
- else
- if command = "toggleRun" then
- toggleRun()
- else
- if command = "pickYeah" then
- pickYeah(value(param))
- else
- if command = "pickNo" then
- pickNo(value(param))
- else
- if command = "chooseMode" then
- chooseMode(param)
- else
- if command = "toggleScore" then
- toggleScore()
- else
- if command = "adjTime" then
- adjTime(param)
- else
- if command = "adjVolume" then
- adjVolume(param)
- else
- if command = "setVolume" then
- setVolume(the mouseV)
- else
- alert("Illegal command: " & pr)
- halt()
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end
-
- on inChallenge
- global gScreenMode
- return getaProp(gScreenMode, #SPECIAL) = #RUN
- end
-
- on pictMode
- global gScreenMode
- if getaProp(gScreenMode, #PCTCHAL) <> #NONE then
- return #challenge
- else
- if getaProp(gScreenMode, #PCTRESP) <> #NONE then
- return #response
- else
- return #notUsed
- end if
- end if
- end
-
- on translateMode mode
- global gMode, gScreenMode
- set gMode to mode
- if mode = "122" then
- set gScreenMode to [#SNDCHAL: #UPLEFT, #TXTCHAL: #top, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #NONE, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #RUN, #mode: "1"]
- else
- if mode = "120" then
- set gScreenMode to [#SNDCHAL: #UPLEFT, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #NONE, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #RUN, #mode: "2"]
- else
- if mode = "102" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #top, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #NONE, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #RUN, #mode: "3"]
- else
- if mode = "121" then
- set gScreenMode to [#SNDCHAL: #UPLEFT, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #NONE, #TXTRESP: #ONPCT, #PCTRESP: #YES, #SPECIAL: #RUN, #mode: "4"]
- else
- if mode = "112" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #top, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #ONPCT, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #RUN, #mode: "5"]
- else
- if mode = "211" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #YES, #SCREEN: #TYPE2, #SNDRESP: #ONTXT, #TXTRESP: #ALONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "6"]
- else
- if mode = "210" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #YES, #SCREEN: #TYPE2, #SNDRESP: #ONTXT, #TXTRESP: #NONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "7"]
- else
- if mode = "201" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #YES, #SCREEN: #TYPE2, #SNDRESP: #NONE, #TXTRESP: #ALONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "8"]
- else
- if mode = "221" then
- set gScreenMode to [#SNDCHAL: #ONPCT, #TXTCHAL: #NONE, #PCTCHAL: #YES, #SCREEN: #TYPE2, #SNDRESP: #NONE, #TXTRESP: #ALONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "9"]
- else
- if mode = "212" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #ONPCT, #PCTCHAL: #YES, #SCREEN: #TYPE2, #SNDRESP: #ONTXT, #TXTRESP: #NONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "10"]
- else
- if mode = "021" then
- set gScreenMode to [#SNDCHAL: #UPLEFT, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE2, #SNDRESP: #NONE, #TXTRESP: #ALONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "11"]
- else
- if mode = "012" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #top, #PCTCHAL: #NONE, #SCREEN: #TYPE2, #SNDRESP: #ONTXT, #TXTRESP: #NONE, #PCTRESP: #NONE, #SPECIAL: #RUN, #mode: "12"]
- else
- if mode = "111" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #ONPCT, #TXTRESP: #ONPCT, #PCTRESP: #YES, #SPECIAL: #BROWSE, #mode: "A"]
- else
- if mode = "110" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #ONPCT, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #BROWSE, #mode: "B"]
- else
- if mode = "011" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #ONPCT, #TXTRESP: #ONPCT, #PCTRESP: #NONE, #SPECIAL: #BROWSE, #mode: "C"]
- else
- if mode = "110dict" then
- set gScreenMode to [#SNDCHAL: #NONE, #TXTCHAL: #NONE, #PCTCHAL: #NONE, #SCREEN: #TYPE1, #SNDRESP: #ONPCT, #TXTRESP: #NONE, #PCTRESP: #YES, #SPECIAL: #DICT, #mode: " "]
- else
- alert("Illegal mode given: " & mode)
- halt()
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- end if
- sort(gScreenMode)
- end
-
- on isBrowse
- global gScreenMode
- set SPECIAL to getaProp(gScreenMode, #SPECIAL)
- if (SPECIAL = #BROWSE) or (SPECIAL = #DICT) then
- return 1
- else
- return 0
- end if
- end
-
- on isDict
- global gScreenMode
- if getaProp(gScreenMode, #SPECIAL) = #DICT then
- return 1
- else
- return 0
- end if
- end
-
- on withinBox l, t, r, b, x, y
- return (x >= l) and (x <= r) and (y >= t) and (y <= b)
- end
-
- on modeNum mode
- return value(char 1 of mode) + (value(char 2 of mode) * 3) + (value(char 3 of mode) * 9) + 1
- end
-
- on clearstuff
- repeat with i = 0 to 39
- set the text of cast (345 + i) to "@"
- end repeat
- repeat with i = 0 to 7
- set the fileName of cast (449 + i) to "BLANK.PCT"
- end repeat
- repeat with i = 0 to 3
- set the text of cast (49 + i) to " "
- set the text of cast (113 + i) to " "
- end repeat
- set the text of cast 2 to " "
- set the text of cast 105 to " "
- set the text of cast 106 to " "
- set the text of cast 42 to " "
- set the text of cast 228 to " "
- put " " into field "login name"
- put " " into field "Password"
- put " " into field "Announce Text"
- clearGlobals()
- end
-
- on formatTime tics
- set mins to tics / 3600
- set hrs to mins / 60
- set mins to mins mod 60
- if mins < 10 then
- set mins to "0" & mins
- end if
- set secs to tics mod 3600 / 60
- if secs < 10 then
- set secs to "0" & secs
- end if
- if hrs > 9 then
- return "9:59:59"
- else
- return string(hrs) & ":" & string(mins) & ":" & string(secs)
- end if
- end
-
- on randMode
- global gMode
- set theModes to "122,122,120,120,102,102,211,211,210,210,201,201,212,012,021,221,112,121"
- set newMode to item random(18) of theModes
- repeat while newMode = gMode
- set newMode to item random(18) of theModes
- end repeat
- return newMode
- end
-
- on randPage currPage
- global gNumPages, gRandPageOrder, gRandPageIndex
- if gRandPageIndex = 0 then
- set gRandPageOrder to EMPTY
- repeat with i = 1 to 10
- set r to random(gNumPages) - 1
- repeat while gRandPageOrder contains string(r)
- set r to random(gNumPages) - 1
- end repeat
- put string(r) & " " after gRandPageOrder
- end repeat
- end if
- set gRandPageIndex to gRandPageIndex + 1
- set nPage to word gRandPageIndex of gRandPageOrder
- if gRandPageIndex = 10 then
- set gRandPageIndex to 0
- end if
- return integer(nPage) + 1
- end
-
- on randomize
- set the randomSeed to the ticks mod 262144
- end
-
- on ChapStr2Unit s
- return value(char 1 to 2 of word 2 of s)
- end
-
- on ChapStr2Chap s
- return value(char 4 to 5 of word 2 of s)
- end
-
- on ChapStr2Language s
- return word 1 of s
- end
-
- on makeChapStr language, unit, chapter
- return language & " " & pad(unit) & "-" & pad(chapter)
- end
-
- on initBroadcast
- set gStackLevel to 0
- set gStack to []
- end
-
- on broadcast str
- if gDebug = 0 then
- return
- else
- if gDebug = #call then
- set ps to string(the frame)
- repeat with i = 0 to gStackLevel
- put " " after ps
- end repeat
- put ps & str
- set gStackLevel to gStackLevel + 1
- add(gStack, word 1 of str)
- else
- if gDebug = #performance then
- set gStackLevel to gStackLevel + 1
- add(gStack, word 1 of str && the ticks)
- end if
- end if
- end if
- end
-
- on popBroad str
- if gDebug = 0 then
- return
- else
- if gDebug = #call then
- set match to getLast(gStack)
- if match <> str then
- put "**** Mismatched stack: " & str && match
- end if
- deleteAt(gStack, count(gStack))
- set gStackLevel to gStackLevel - 1
- if gStackLevel < 0 then
- put "**** Stack level is negative!" && gStackLevel
- else
- nothing()
- end if
- else
- if gDebug = #performance then
- set t to the ticks
- set match to getLast(gStack)
- if word 1 of match <> str then
- put "**** Mismatched stack: " & str && match
- end if
- deleteAt(gStack, count(gStack))
- set ps to EMPTY
- repeat with i = 0 to gStackLevel
- put " " after ps
- end repeat
- put ps & str && t - value(word 2 of match) && t mod 4096
- set gStackLevel to gStackLevel - 1
- if gStackLevel < 0 then
- put "**** Stack level is negative!" && gStackLevel
- else
- nothing()
- end if
- end if
- end if
- end if
- end
-